//
//  HLShareLinkCell.m
//  YueYue
//
//  Created by hulu001 on 2023/9/21.
//

#import "HLShareLinkCell.h"

@interface HLShareLinkCell ()

@property (nonatomic, strong) UIView *backView;
@property (nonatomic, strong) UIImageView *imageView;
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *descLabel;

@end

@implementation HLShareLinkCell


-(instancetype)initWithFrame:(CGRect)frame{
    
    if ([super initWithFrame:frame]) {
        self.backgroundColor= UIColorWhite;
        [self setupView];
    }
    return self;
    
}

- (void)setupView
{
    self.backView = [[UIView alloc] init];
    _backView.layer.masksToBounds = YES;
    _backView.layer.cornerRadius = 9;
    _backView.layer.borderColor = HLLineColor.CGColor;
    _backView.layer.borderWidth = 1;
    [self.contentView addSubview:_backView];
    [_backView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.mas_equalTo(12);
        make.right.bottom.mas_equalTo(-12);
    }];
    
    self.imageView = [[UIImageView alloc] init];
    _imageView.image = UIImageMake(@"sharelink_placeholder");
    _imageView.contentMode = UIViewContentModeScaleAspectFit;
    [_backView addSubview:_imageView];
    [_imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(10);
        make.right.bottom.mas_equalTo(-10);
        make.width.equalTo(_imageView.mas_height);
    }];
    
    self.titleLabel = [[UILabel alloc] qmui_initWithFont:UIFontMediumMake(14) textColor:HLTextColor1];
    _titleLabel.numberOfLines = 0;
    [_backView addSubview:_titleLabel];
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(16);
        make.top.mas_equalTo(12);
        make.right.mas_equalTo(-100);
    }];
    
    self.descLabel = [[UILabel alloc] qmui_initWithFont:UIFontMake(12) textColor:HLTextColor2];
    _descLabel.numberOfLines = 0;
    [_backView addSubview:_descLabel];
    [_descLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(_titleLabel);
        make.top.equalTo(_titleLabel.mas_bottom).offset(12);
    }];
    
}


-(void)setModel:(HLShareLinkModel *)model
{
    _model = model;
    [_imageView sd_setImageWithURL:[NSURL URLWithString:model.linkImgUrl] placeholderImage:UIImageMake(@"sharelink_placeholder")];
    _titleLabel.text = model.title;
    _descLabel.text = model.content;
    if (model.isChange) {
        self.backView.layer.borderColor = HLMainColor.CGColor;
        self.backView.backgroundColor = [HLMainColor colorWithAlphaComponent:0.2];
    }else{
        self.backView.layer.borderColor = HLLineColor.CGColor;
        self.backView.backgroundColor =  UIColorWhite;
    }
  
    
}


+ (NSString *)identifyCell
{
    return NSStringFromClass([self class]);
}

@end
